<?php
/**
 * CreateUser: zlh
 * CreateTime: 2022/4/29 9:56
 * Remark:
 */

namespace App\ServiceChecker;

use App\Consts\BaseConsts\BaseConsts;
use App\Consts\ResponseConsts\ResponseStatusConsts;
use App\Func\ResponseFunc;
use App\Func\TokenFuc;
use App\Models\Company\CompanyModel;
use Illuminate\Http\Exceptions\HttpResponseException;

class BasicServiceChecker
{
    protected CompanyModel $_companyModel;
    protected mixed $currentStaff;

    public function __construct()
    {
        $this->_companyModel = new CompanyModel();
//        $this->currentStaff = TokenFuc::getCurrentStaffInfo();
    }

    /**
     * 校验公司名称是否存在
     * @param $companyName
     */
    public function verifyCompanyIsExists($companyId){
        $isExist = $this->_companyModel->isExistByCondition([
            'company_id' => $companyId,
            'status' => BaseConsts::STATUS_NORMAL
        ]);
        if(!$isExist){
            throw new HttpResponseException( ResponseFunc::returnJson(
                'error',
                null,
                "当前公司不存在",
                ResponseStatusConsts::OK_200_RESPONSE_STATUS,

            ));
        }
    }
}